#include <stdio.h>
#include <stdlib.h>
struct node{
	int id;
	int score;
}node;

int compare(const void* p1, const void* p2)
{
	return *(int *)p2 - *(int *)p1;
}

int main()
{
	int N = 0, i = 0;
	int input[100000] = {0};
	int id = 0, score = 0;
	int maxId = 0, max = 0;
	scanf("%d", &N);
	for(i = 0; i < N; i++){
		scanf("%d %d", &id, &score);
		input[id] += score;
	}
	
	for(i = 0; i < N; i++){
		if(input[i] > max){
			maxId = i;
			max = input[i];
		}
	}

	printf("\n%d %d\n", maxId, input[maxId]);
}
